<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 17:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>增加学员信息</title>
    <!--使用Bootstrap-->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <!--引入js-->
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<style>
    table{
        margin: 0 auto;/*居中*/
        height: 300px;/*表格高度*/
    }

    td{
        width:100px;
    }

    div{
        width: 400px;
        margin:0 auto;
        text-align: center;
    }
</style>
<body>
<%--功能块--%>
<div>
    <h2>新增学员</h2>
    <%--数据提交到AddServlet中--%>
    <form action="add" method="post" onsubmit="return finish()" class="well">
        <table>
            <tr>
                <td>学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</td>
                <td><input type="text" name="num" id="num" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');"></td>
            </tr>
            <tr>
                <td>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</td>
                <td><input type="text" name="name" id="name"></td>
            </tr>
            <tr>
                <td>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别</td>
                <td>
                    <input type="radio" name="sex" value="男" checked>男
                    <input type="radio" name="sex" value="女">女
                </td>
            </tr>
            <tr>
                <td>出生日期</td>
                <td><input type="date" name="date" min="1919-01-01" max="2019-12-31" value="2000-01-01"></td>
            </tr>
            <tr>
                <td>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱</td>
                <td><input type="email" name="email" id="email"></td>
            </tr>
            <tr>
                <td>备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</td>
                <td><input type="text" name="remark"></td>
            </tr>
            <tr>
                <td>班级编号</td>
                <td>
                    <select name="classId">
                        <c:forEach var="i" items="${sessionScope.allClassesId}">
                            <option value="${i}">${i}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
        </table>
            <input type="submit" class="btn btn-info" value="确定">
            <input type="button" class="btn btn-danger" value="取消" onclick="main()">
            <%--提示信息，例如学号已存在，有未填信息等--%>
            <span style="color:red">
                <%--<%= request.getAttribute("numError")==null?"":request.getAttribute("numError") %>--%>
                ${numError==null?"":numError}
            </span><br/>

    </form>
</div>
</body>
<script>
    //点击提交时调用这个方法，用于检查是否有未填信息
    function finish() {
        //声明变量用于记录用户名输入框中的值，使用DOM操作
        var num = document.getElementById("num").value;
        var name = document.getElementById("name").value;
        var email = document.getElementById("email").value;
        if (num=="" || name=="" || email=="" ) {
            alert("请将信息填写完整");
            return false;
        }
    }
    //点击取消时调用这个方法，跳转到ShowServlet，再回到主页
    function main() {
        //拼接url
        var url = "show?";
        url += "start="+0;
        //重新定位url
        location = url;
    }


</script>
</html>
